cmake_minimum_required(VERSION 3.15)
project(MyProject)

# 添加自定义模块的路径
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules)

# 查找 MyLib 库
find_package(MyLib REQUIRED)

# 如果 MyLib 找到
if(MyLib_FOUND)
    message(STATUS "MyLib 库已找到")
    message(STATUS "MyLib include 目录: ${MyLib_INCLUDE_DIRS}")
    message(STATUS "MyLib 库文件: ${MyLib_LIBRARIES}")
    message(STATUS "MyLib 版本: ${MyLib_VERSION}")

    # 添加头文件搜索路径
    include_directories(${MyLib_INCLUDE_DIRS})

    # 添加一个可执行文件
    add_executable(MyProject main.cpp)

    # 链接 MyLib 库
    target_link_libraries(MyProject ${MyLib_LIBRARIES})
else()
    message(FATAL_ERROR "找不到 MyLib 库")
endif()